﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace Cloak.Mvvm.Navigation
{
	/// <summary>
	/// A reference to a type of view model associated with a page and identified by a name
	/// </summary>
	public sealed class NamedPageModelReference : PageModelReference
	{
		/// <summary>
		/// Initializes an instance of <see cref="NamedPageModelReference"/>
		/// </summary>
		/// <param name="viewModelType">The type of view model referenced by the page</param>
		/// <param name="viewModelName">The name of the view model referenced by the page</param>
		/// <param name="parameters">The parameters available when creating the view model</param>
		public NamedPageModelReference(Type viewModelType, string viewModelName, IEnumerable<PageModelParameter> parameters)
			: base(viewModelType, parameters)
		{
			Contract.Requires(viewModelName != null);

			ViewModelName = viewModelName;
		}

		/// <summary>
		/// Initializes an instance of <see cref="NamedPageModelReference"/>
		/// </summary>
		/// <param name="viewModelType">The type of view model referenced by the page</param>
		/// <param name="viewModelName">The name of the view model referenced by the page</param>
		/// <param name="parameters">The parameters available when creating the view model</param>
		public NamedPageModelReference(Type viewModelType, string viewModelName, params PageModelParameter[] parameters)
			: this(viewModelType, viewModelName, parameters as IEnumerable<PageModelParameter>)
		{}

		/// <summary>
		/// Gets the name of the view model referenced by the page
		/// </summary>
		public string ViewModelName { get; private set; }
	}
}